import java.util.Arrays;

public class TwoSum {
    public int[] twoSum(int[] price, int target) {
        int left = 0, right = price.length - 1;
        while(left < right){
            int sum = price[left] + price[right];
            if (sum > target) {
                right--;
            }else if(sum < target){
                left++;
            }else {
                return new int[] {price[left],price[right]};
            }
        }
        return new int[]{0};
    }

    public static void main(String[] args) {
        TwoSum twoSum = new TwoSum();
        int[] number = {2 , 7, 11 , 15};
        System.out.println(Arrays.toString(twoSum.twoSum(number,9)));

    }
}
